import 'package:audioplayers/audioplayers.dart';
// import 'package:audioplayers/audio_cache.dart';
import 'package:flutter/foundation.dart';

class Audio {
  // static AudioCache player = AudioCache();

  static AudioPlayer player = AudioPlayer();

  //
  // Initialization.  We pre-load all sounds.
  //
  // static Future<dynamic> init() async {
  //   await player.loadAll([
  //     'audio/swap.wav',
  //     'audio/move_down.wav',
  //     'audio/bomb.wav',
  //     'audio/game_start.wav',
  //     'audio/win.wav',
  //     'audio/lost.wav',
  //   ]);
  // }

  static play() async {
    // AudioPlayer player = AudioPlayer();
    await player.play(AssetSource('audio/swap.wav'));
    // await player.play('assets/audio/swap.wav', isLocal: true);
  }

  static playAsset(AudioType audioType) {
    // player.play('audio/${describeEnum(audioType)}.wav');
    player.play(AssetSource('audio/${describeEnum(audioType)}.wav'));
  }
}

enum AudioType {
  swap,
  // ignore: constant_identifier_names
  move_down,
  bomb,
  // ignore: constant_identifier_names
  game_start,
  win,
  lost,
}
